package classfile

/*
CONSTANT_Fieldref_info {
    u1 tag;
    u2 class_index;
    u2 name_and_type_index;
}
CONSTANT_Methodref_info {
    u1 tag;
    u2 class_index;
    u2 name_and_type_index;
}
CONSTANT_InterfaceMethodref_info {
    u1 tag;
    u2 class_index;
    u2 name_and_type_index;
}
*/

type ConstantMemberRefInfo struct {
	cp               ConstantPool
	classIndex       uint16
	nameAndTypeIndex uint16
}

func (cmri *ConstantMemberRefInfo) readInfo(reader *ClassReader) {
	cmri.classIndex = reader.readUint16()
	cmri.nameAndTypeIndex = reader.readUint16()
}

func (cmri *ConstantMemberRefInfo) ClassName() string {
	return cmri.cp.getClassName(cmri.classIndex)
}

func (cmri *ConstantMemberRefInfo) NameAndDescriptor() (string, string) {
	return cmri.cp.getNameAndType(cmri.nameAndTypeIndex)
}

type ConstantFieldRefInfo struct {
	ConstantMemberRefInfo
}

type ConstantMethodRefInfo struct {
	ConstantMemberRefInfo
}

type ConstantInterfaceMethodRefInfo struct {
	ConstantMemberRefInfo
}
